package xhhx.logic;

import simpleProtobuf.SimpleProtobuf.ChangeName;
import simpleProtobuf.SimpleProtobuf.ChangeNameRt;
import xhhx.cache.PlayerCache;
import xhhx.manager.DataManager;
import xhhx.session.Player;

public class ChangeNameProcessor extends Processor<ChangeName, ChangeNameRt> {
    @Override
    protected ChangeNameRt deal(ChangeName cn, PlayerCache playerCache) {
        ChangeNameRt.Builder rt = ChangeNameRt.newBuilder();
        Player p = playerCache.player;
        p.setName(cn.getNewName());
        DataManager.Update(p);
        rt
                .setRt(1)
                .setNewName(p.getName());
        return rt.build();
    }
}
